/*
 * ULSF Sagittarius IDA
 * Copyright (C) 2012, John Pritchard, all rights reserved.
 * 
 * This program is free software: you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see
 * <http://www.gnu.org/licenses/>.
 */
package sagittarius.design;

import sagittarius.Field;
import sagittarius.Visualization;

import sagittarius.airfoil.Airfoil;

/**
 * This {@link Volume} operator for {@link SectionHyperbolicWing}
 * operators defines a {@link SearsHaack Sears-Haack} body in {@link
 * SectionHyperbolic hyperbolic sections} having span distribution.
 * 
 * @see Volume
 * @see Section
 * @see Body
 */
public class SearsHaackHyperbolicWing
    extends SearsHaack.RL
{

    private final static double CU = 0.1;


    public SearsHaackHyperbolicWing(Visualization data){
        super(data);
    }


    @Override
    public Section stationForX(double station, double x){

        final Section.Key key = new Section.Key(station);

        Section section = this.get(key);

        if (null == section){

            final double u = this.uniform(station);
            if (CU < u){

                section = new SectionHyperbolicWing(this,station,x,u);
            }
            else
                section = new SectionCircle(this, station);

            this.put(key,section);
        }
        return section;
    }
}
